package com.qyer.search.model.aggregation;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Created by tangzheng on 16/7/17.
 */
public class TravelDay implements Comparable<TravelDay>{

  @JsonProperty
  private int day;
  @JsonIgnore
  private int size;

  public TravelDay(int day) {
    this.day = day;
  }

  public TravelDay(int day, int size) {
    this.day = day;
    this.size = size;
  }

  @Override public boolean equals(Object o) {
    if (this == o)
      return true;
    if (o == null || getClass() != o.getClass())
      return false;

    TravelDay travelDay = (TravelDay) o;

    return day == travelDay.day;

  }

  @Override public int hashCode() {
    return day;
  }

  public int getDay() {
    return day;
  }

  public void setDay(int day) {
    this.day = day;
  }

  public int getSize() {
    return size;
  }

  public void setSize(int size) {
    this.size = size;
  }

  @Override public int compareTo(TravelDay travelDay) {
    return (travelDay.getSize() - this.size);
  }

  public void add(TravelDay travelDay){
    if(this.day == travelDay.getDay()){
      this.size += travelDay.getSize();
    }
  }
}
